<?php
$sql="
	CREATE DATABASE IF NOT EXISTS 58jitu default character set utf8 COLLATE utf8_general_ci;
	USE 58jitu;
	CREATE TABLE IF NOT EXISTS `58__admin`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
		`name` varchar(50) NOT NULL COMMENT '用户名' UNIQUE,
		`password` varchar(50) NOT NULL COMMENT '用户密码',
		`vippay` tinyint(50) NOT NULL COMMENT 'vip付款钱数每年',
		`freighttime` tinyint(50) NOT NULL COMMENT '转载次数设置',
		`qqkey` varchar(50) NOT NULL COMMENT 'qqkey',
		`qqsecret` varchar(50) NOT NULL COMMENT 'qqsecret',
		`sinakey` varchar(50) NOT NULL COMMENT 'sinakey',
		`sinasecret` varchar(50) NOT NULL COMMENT 'sinasecret',	
		`alipaykey` varchar(50) NOT NULL COMMENT 'alipaykey',
		`alipaysecret` varchar(50) NOT NULL COMMENT 'alipaysecret',
		`qiniukey` varchar(50) NOT NULL COMMENT 'quniukey',
		`qiniusecret` varchar(50) NOT NULL COMMENT 'qiniusecret',
		`bucket` varchar(50) NOT NULL COMMENT 'bucket',
		`qiniuurl` varchar(500) NOT NULL COMMENT 'qiniuurl',
		`qiniustatus` tinyint(5) DEFAULT 0 NOT NULL COMMENT 'qiniustatus',
		`homenotice` varchar(100) NOT NULL COMMENT '主页广告栏文字信息',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
	INSERT INTO `58__admin`(`name`,`password`) VALUES ('admin',MD5('123456'));
		
	CREATE TABLE IF NOT EXISTS `58__lunbo`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '轮播图片id',
		`lunboorder` tinyint(5) NOT NULL COMMENT '轮播图片排列序号' UNIQUE,
		`title` varchar(50) NOT NULL COMMENT '轮播标题',
		`imgurl` varchar(500) NOT NULL COMMENT '轮播图片url',
		`status` tinyint(5) NOT NULL COMMENT '状态（0位禁用，1为正常)',
		`clickurl` varchar(50) NOT NULL COMMENT '轮播图片链接',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__ad`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '广告id',
		`adorder` bigint(255) NOT NULL COMMENT '广告排列序号',
		`admessage` varchar(500) NOT NULL COMMENT '广告文字信息',
		`imgurl` varchar(500) NOT NULL COMMENT '广告图片url',
		`status` tinyint(5) NOT NULL COMMENT '状态（0位禁用，1为正常)',
		`writerimgurl` varchar(500) NOT NULL COMMENT '广告作者头像链接',
		`writer` varchar(50) NOT NULL COMMENT '广告作者名',
		`clickurl` varchar(50) NOT NULL COMMENT '广告点击链接',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__vip`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'vip账户id',
		`serialnumber` varchar(50) NOT NULL COMMENT 'vip用户流水号' UNIQUE,
		`serialtime` tinyint(50) NOT NULL COMMENT 'vip用户买了几年',
		`releasetime` tinyint(50) NOT NULL COMMENT 'vip用户剩下来的时间',
		`borntime` tinyint(50) NOT NULL COMMENT 'vip用户购买时间',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

	CREATE TABLE IF NOT EXISTS `58__user`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
		`serialnumber` varchar(50) NOT NULL COMMENT '用户流水号' UNIQUE,
		`phone` varchar(50) NOT NULL COMMENT '手机号码',
		`phonename` varchar(50) NOT NULL COMMENT '手机联系人',
		`usertype` tinyint(5) NOT NULL COMMENT '1为手机用户2为qq用户3为微信用户4为支付宝用户5为微博用户',
		`name` varchar(50) NOT NULL COMMENT '用户名',
		`nickname` varchar(50) NOT NULL COMMENT '昵称',
		`headimg` varchar(500) NOT NULL COMMENT '头像图片地址',
		`password` varchar(50) NOT NULL COMMENT '用户密码',
		`mail` varchar(50) NOT NULL COMMENT '邮箱',
		`mainuri` varchar(50) NOT NULL COMMENT '主页网址',
		`accounttype` tinyint(5) NOT NULL DEFAULT 0 COMMENT '账户类型（0为普通账户1为vip账户）',
		`vipyear` tinyint(50) NOT NULL COMMENT '购买vip年数',
		`memberimgurl` varchar(500) NOT NULL COMMENT '个人横幅图片',
		`borntime` varchar(50) NOT NULL COMMENT '出生年月日',
		`bornaddress` varchar(50) NOT NULL COMMENT '出生地点',
		`logintime` varchar(50) NOT NULL COMMENT '注册时间',
		`freightpassword` varchar(50) NOT NULL COMMENT '装载密码',
		`albumordertype` tinyint(5) DEFAULT 1 NOT NULL COMMENT '相册排序方式（1为时间前后，2为创建时间，3为名称排列，4为自定义）',
		`status` tinyint(5) DEFAULT 1 NOT NULL COMMENT '1为正常状态，0为禁用状态',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__userphone`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '手机用户id',
		`phonephone` varchar(50) NOT NULL COMMENT '手机号码',
		`phoneserialnumber` varchar(50) NOT NULL COMMENT '流水号（和notice表serialnumber相同）（和vip表serialnumber相同）' UNIQUE,
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__userqq`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'qq用户id',
		`qq` varchar(50) NOT NULL COMMENT 'qq号码',
		`qqserialnumber` varchar(50) NOT NULL COMMENT '流水号（和notice表serialnumber相同）（和vip表serialnumber相同）' UNIQUE,
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__usersina`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '新浪用户id',
		`weibo` varchar(50) NOT NULL COMMENT '微博账号',
		`sinaserialnumber` varchar(50) NOT NULL COMMENT '流水号（和notice表serialnumber相同）（和vip表serialnumber相同）' UNIQUE,
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__userweixin`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '微信用户id',
		`weixin` varchar(50) NOT NULL COMMENT '微信账号',
		`weixinserialnumber` varchar(50) NOT NULL COMMENT '流水号（和notice表serialnumber相同）（和vip表serialnumber相同）' UNIQUE,
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
		
	CREATE TABLE IF NOT EXISTS `58__userpaybao`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '支付宝用户id',
		`payerbao` varchar(50) NOT NULL COMMENT '支付宝账号',
		`paybaoserialnumber` varchar(50) NOT NULL COMMENT '流水号（和notice表serialnumber相同）（和vip表serialnumber相同）' UNIQUE,
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

	CREATE TABLE IF NOT EXISTS `58__notice`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '公告id',
		`serialnumber` varchar(50) NOT NULL COMMENT '公告所属会员流水id',
		`noticetitle` varchar(50) NOT NULL COMMENT '公告标题',
		`noticemessage` longtext NOT NULL COMMENT '公告内容',
		`noticeorder` bigint(225) NOT NULL COMMENT '公告排序',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;		
		
	CREATE TABLE IF NOT EXISTS `58__ad`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '广告id',
		`imgurl` varchar(50) NOT NULL COMMENT '广告位图片链接',
		`charmessage` varchar(50) NOT NULL COMMENT '广告位文字信息',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;	
	
	CREATE TABLE IF NOT EXISTS `58__theme`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '相册模板id',
		`themename` varchar(50) NOT NULL AUTO_INCREMENT COMMENT '相册主题名称',
		`photoframeimgurl` varchar(500) NOT NULL COMMENT '相框图片路径',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;			

	CREATE TABLE IF NOT EXISTS `58__img`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '图片id',
		`imgurl` varchar(50) NOT NULL COMMENT '图片链接',
		`albumid` int(50) NOT NULL COMMENT '相册id',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;	
	
	CREATE TABLE IF NOT EXISTS `58__albumtype`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '相册分类id',
		`ordernum` int(50) NOT NULL COMMENT '相册排序号',
		`typename` varchar(50) NOT NULL COMMENT '相册分类名',
		`serialnumber` varchar(50) NOT NULL COMMENT '相册分类创建者',
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;	
	CREATE TABLE IF NOT EXISTS `58__album`(
		`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '相册id',
		`typeid` tinyint(11) NOT NULL COMMENT '相册分类id',
		`themeid` tinyint(11) NOT NULL COMMENT '相册模板id',
		`albumorder` bigint(255) NOT NULL COMMENT '相册排序序号',
		`serialnumber` varchar(50) NOT NULL COMMENT '相册创建者',
		`albumname` varchar(50) NOT NULL COMMENT '相册名字',
		`albummessage` varchar(50) NOT NULL COMMENT '相册描述',
		`albumimgid` varchar(50) NOT NULL COMMENT '相册包含图片id的json字符串',
		`borntime` bigint(255) NOT NULL COMMENT '相册创建时间',
		`password` varchar(50) NOT NULL COMMENT '相册密码', 
		PRIMARY KEY (`id`)
	)ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;			
		";
	$dbh = new PDO('mysql:host=localhost;dbname=58jitu', 'root', '123456');
	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$dbh->exec('set names utf8');
	$stmt = $dbh->prepare($sql);
	$stmt->execute();
?>